package com.weiweiqin.controller.home;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.weiweiqin.model.WebInfo;
import com.weiweiqin.service.WebInfoService;
import com.weiweiqin.vo.common.Page;
import com.weiweiqin.vo.common.Result;

@Controller
@RequestMapping("front/webinfo")
public class FWebInfoController {

	@Autowired
	private WebInfoService webInfoService;
	  
	/**
	 * 首页获取网站信息
	 * @return
	 */
	@RequestMapping(value = "/getWebInfo.do", method = { RequestMethod.POST,
			RequestMethod.GET })
	@ResponseBody
	public String getWebInfo(){
		Result result = new Result();
		Page page = new Page();
		Map<String,Object> conditions = new HashMap<String, Object>();
		List<WebInfo> webInfoList = webInfoService.pageList(page, conditions);
		if(null == webInfoList || webInfoList.isEmpty()){
			result.setResult(false);
			result.setErrorMsg("没有可以显示的网站信息");
			return result.toJson();
		}else{
			WebInfo webInfo = webInfoList.get(0);
			result.setResult(true);
			result.setObj(webInfo);
			return result.toJson();
		}
	}
}
